package vn.team.clipxonxao.respone;

import org.json.JSONException;
import org.json.JSONObject;

import vn.team.clipxonxao.utils.ConfigApp;

import com.mk.fw.connection.APIDataResponse;
import com.mk.fw.connection.APIResponse;

public class TotalPageRespone extends APIResponse{

	private int totalPage;
	
	public TotalPageRespone(APIDataResponse dataResponse) {
		super(dataResponse);
	}

	@Override
	public void parseResponse(APIDataResponse response) {
		if (response == null) {
			return;
		}
		try {
			if(response.getData()!=null && response.getData().compareTo("")!=0){
				JSONObject jsonObject = new JSONObject(response.getData());
				int code = jsonObject.getInt(ConfigApp.CODE);
				if (code == APIResponse.SERVER_SUCCESS) {
					totalPage = jsonObject.getInt(ConfigApp.PAGECOUNT);
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
			setCode(APIResponse.CLIENT_ERROR_PARSE_DATA);
		}
	}
	
	public int getTotalPage() {
		return totalPage;
	}
}
